package BLL;

import DAL.BooksDao;
import DAL.BooksTypeDao;
import DAL.LogDao;
import Entity.BCategory;
import Entity.Books;
import org.junit.Test;

import java.util.Date;
import java.util.List;

/**
 * 图书信息增删改查
 * @Author Chen
 * @Date 2022/1/6 19:18
 * @Version 1.0
 */
public class BookService {
    private static LogDao ld=new LogDao();
    private static BooksDao bookDao=new BooksDao();
    private static BooksTypeDao bookTypeDao=new BooksTypeDao();
    //图书信息增加
    public static int addBook(Object... args){
        int i = bookDao.addBook(args);
        Date date=new Date();
        String s="添加了图书信息！";
        ld.insertloginLog(date,s);
        return i;
    }

    //图书信息修改
    public static int modifyBook(Object... args){
        int i = bookDao.updateBook(args);
        Date date=new Date();
        String s="修改了图书信息！";
        ld.insertloginLog(date,s);
        return i;
    }

    //图书信息删除
    public static int deleteBook(Object... args){
        int i = bookDao.deleteBook(args);
        Date date=new Date();
        String s="删除了图书信息！";
        ld.insertloginLog(date,s);
        return i;
    }
    //查询所有图书
    public static List<Books> selectBook(){
        List<Books> books = bookDao.selectAllBooks();
        Date date=new Date();
        String s="查询了图书信息！";
        ld.insertloginLog(date,s);
        return books;
    }
    //根据id查询图书
    public static Books selectBookById(Object... args) {
        Books books = bookDao.selectBookById(args);
        Date date=new Date();
        String s="根据id查询图书信息！";
        ld.insertloginLog(date,s);
        return books;
    }
    //图书类别信息显示
    public static List<BCategory> queryBookType(){
        List<BCategory> bc = bookTypeDao.selectBookType();
        Date date=new Date();
        String s="图书类别信息显示！";
        ld.insertloginLog(date,s);
        return bc;
    }
    //根据书名查询内容
    public static List<Books> selectBookName(Object... args){
        List<Books> books = bookDao.selectBookByName(args);
        Date date=new Date();
        String s="根据书名查询内容！";
        ld.insertloginLog(date,s);
        return books;
    }
    //根据图书类型编号查询
    public static List<Books> selectBookType(Object... args){
        List<Books> books = bookDao.selectBookByType(args);
        Date date=new Date();
        String s="根据图书类型编号查询！";
        ld.insertloginLog(date,s);
        return books;
    }

}
